﻿using System;
using System.Configuration;
using mojoPortal.Net;
using mojoPortal.Web;
using Resources;
using mojoPortal.Web.Framework;
using System.Collections;
using mojoPortal.Business;
using ud_gSDMS.Code_Service;
using mojoPortal.Business.WebHelpers;
using System.IO;
using Brettle.Web.NeatUpload;
using System.Collections.Generic;
using System.Web.UI.WebControls;
using System.Web.UI;
namespace ud_gSDMS.Member
{
    public partial class UpdateLuong_HSPC : mojoBasePage
    {
        private int pageId = -1;
        private int moduleId = -1;
        private string id;
        private SiteUser _siteUser;
        protected String cacheDependencyKey;
        
        void Page_Load(object sender, EventArgs e)
        {
            _siteUser = SiteUtils.GetCurrentSiteUser();
            if (_siteUser == null)
            {
                WebUtils.SetupRedirect(this, SiteRoot + "/AccessDenied.aspx");
            }

            if (!Page.IsPostBack)
            {
                PopulateLabels();
                PopulateControls();
            }
        }
        private void PopulateLabels()
        {
            DBQLNS _respository = new DBQLNS();
            HSLPCTest child1 = new HSLPCTest("1", "0375", "Dương Anh Đức", "15.110", "5", "5.76", "- -", "LGHS", "9.00", "", "", "0.25", "",
                    "", "", "", "", "");
            HSLPCTest child2 = new HSLPCTest("2", "0002", "Trần Vĩnh Phước", "15.110", "7", "6.44", "01-11-2011", "LGHS", "7.00", "0.80", "1.50", "0.25", "",
                "", "", "", "", "");
            HSLPCTest child3 = new HSLPCTest("3", "0003", "Dương Tôn Đảm", "15.110", "8", "6.78", "01-09-2011", "LGHS", "7.00", "0.80", "2.75", "0.25", "",
                "", "", "", "0.05", "");
            List<HSLPCTest> lst = new List<HSLPCTest>();
            lst.Add(child1);
            lst.Add(child2);
            lst.Add(child3);
            Session["HSPC"] = lst;
        }
        private void BindData()
        {
            gvChildInfo.DataSource = Session["HSPC"];
            gvChildInfo.DataBind();
        }

        private void PopulateControls()
        {
            BindData();
        }
        #region OnInit

        protected override void OnPreInit(EventArgs e)
        {
            AllowSkinOverride = true;
            base.OnPreInit(e);
            Load += Page_Load;
        }

        protected override void OnInit(EventArgs e)
        {
            LoadParams();
            LoadPanels();
            base.OnInit(e);
            SuppressPageMenu();
        }

        private void LoadParams()
        {
            pageId = WebUtils.ParseInt32FromQueryString("pageid", pageId);
            moduleId = WebUtils.ParseInt32FromQueryString("mid", true, moduleId);
            id = WebUtils.ParseStringFromQueryString("id", id);
            cacheDependencyKey = "Module-" + moduleId.ToInvariantString();
        }

        private void LoadPanels()
        {
            bool showLeftColumnAdmin = ConfigHelper.GetBoolProperty("ShowLeftColumnAdmin", false);
            bool showRightColumnAdmin = ConfigHelper.GetBoolProperty("ShowRightColumnAdmin", false);
            bool showTopColumnAdmin = ConfigHelper.GetBoolProperty("ShowTopColumnAdmin", false);
            bool showBottomColumnAdmin = ConfigHelper.GetBoolProperty("ShowBottomColumnAdmin", false);
            int showCenterColumnAdmin = ConfigHelper.GetIntProperty("ShowCenterColumnAdmin", 0);
            LoadSideContent(showLeftColumnAdmin, showRightColumnAdmin, showTopColumnAdmin, showBottomColumnAdmin, showCenterColumnAdmin);
        }
        #endregion

        protected void gvChildInfo_RowEditing(object sender, GridViewEditEventArgs e)
        {
            gvChildInfo.EditIndex = e.NewEditIndex;
            BindData();
        }

        protected void gvChildInfo_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
        {
            gvChildInfo.EditIndex = -1;
            BindData();
        }

        protected void gvChildInfo_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            List<HSLPCTest> l = (List<HSLPCTest>)Session["HSPC"];
            TextBox txt_maso = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt1");
            TextBox txt_hoten = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt2");
            TextBox txt_ngach = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt3");
            TextBox txt_bac = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt4");
            TextBox txt_hslg = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt5");
            TextBox txt_ngaytlgn = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt6");
            TextBox txt_hskh = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt7");
            TextBox txt_pctn = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt8");
            TextBox txt_pccv = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt9");
            TextBox txt_pckn = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt10");
            TextBox txt_pcud = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt11");
            TextBox txt_pcth = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt12");
            TextBox txt_pcdh = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt13");
            TextBox txt_pckv = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt14");
            TextBox txt_pcdt = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt15");
            TextBox txt_pcvk = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt16");
            TextBox txt_pckh = (TextBox)gvChildInfo.Rows[e.RowIndex].FindControl("txt17");
            
            string tam = l[e.RowIndex].ID;
            HSLPCTest news = new HSLPCTest(tam, txt_maso.Text, txt_hoten.Text, txt_ngach.Text, txt_bac.Text, txt_hslg.Text,
                txt_ngaytlgn.Text, txt_hskh.Text, txt_pctn.Text, txt_pccv.Text, txt_pckn.Text, txt_pcud.Text, txt_pcth.Text, txt_pcdh.Text
                , txt_pckv.Text, txt_pcdt.Text, txt_pcvk.Text, txt_pckh.Text);
            l[e.RowIndex] = news;
            gvChildInfo.EditIndex = -1;
            BindData();
        }

        protected void gvChildInfo_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            List<HSLPCTest> l = (List<HSLPCTest>)Session["HSPC"];
            l.RemoveAt(e.RowIndex);
            BindData();
        }
    }

    public class HSLPCTest
    {
        public string ID { get; set; }
        public string MaSo { get; set; }
        public string HoTen {get ; set;}    
        public string Ngach { get; set; }
        public string Bac { get; set; }
        public string HSLg { get; set; }
        public string NgayTLGN { get; set; }
        public string HSKH { get; set; }
        public string PCTN { get; set; }
        public string PCCV { get; set; }
        public string PCKN { get; set; }
        public string PCUD { get; set; }
        public string PCTH { get; set; }
        public string PCDH { get; set; }
        public string PCKV { get; set; }
        public string PCĐT { get; set; }
        public string PCVK { get; set; }
        public string PCKH { get; set; }
        public HSLPCTest(string id, string maso, string hoten, string ngach, string bac, string hsLg, string ngayTLGN, string hsKH, string pcTN, string pcCV,
            string PCKN, string PCUD, string PCTH, string PCDH, string PCKV, string PCĐT, string PCVK, string PCKH)
        {
            this.ID = id;
            this.MaSo = maso;
            this.HoTen = hoten;
            this.Ngach = ngach;
            this.Bac = bac;
            this.HSLg = hsLg;
            this.NgayTLGN = ngayTLGN;
            this.HSKH = hsKH;
            this.PCTN = pcTN;
            this.PCCV = pcCV;
            this.PCKN = PCKN;
            this.PCUD = PCUD;
            this.PCTH = PCTH;
            this.PCDH = PCDH;
            this.PCKV = PCKV;
            this.PCĐT = PCĐT;
            this.PCVK = PCVK;
            this.PCKH = PCKH;
        }
    }

    
}